<template>
  <div id="app">
  

     <keep-alive>
      <router-view v-if="$route.meta.keepAlive" />
    </keep-alive>
 
    <router-view v-if="!$route.meta.keepAlive" />
    <!-- tabbar -->
    <van-tabbar route
                active-color='#8c4846'
                ref='tabbar'
                v-if='tabbar==true'>
      <van-tabbar-item replace
                       :to="item.href"
                       v-for='(item,index) in tab'
                       :key='index'
      >
        <span>{{item.content}}</span>
        <template slot="icon"
                  slot-scope="props">
          <img :src="props.active ? item.active : item.normal">
        </template>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import Atitle from "@/components/Atitle";
import Afooter from "@/components/Afooter";
import { setStore, getStore } from "@/config/mUtils";

export default {
  name: "App",
  components: {
    Atitle,
    Afooter
  },
  data() {
    return {
      //公用的配置信息
      UserInfoPage: {},
      email: "", //邮箱
      phone: "", //固定电话
      tabbar: true,
      imgUrl: "http://menpuwang.com/",
      RouterStr1: "",
      tab: [
        {
          normal: require("../static/footer/ioc-01.png"),
          active: require("../static/footer/ioc--01.png"),
          content: "首页",
          href: "/home"
        },
        {
          normal: require("../static/footer/ioc-03.png"),
          active: require("../static/footer/ioc--03.png"),
          content: "发布",
          href: "/issue"
        },
        // {
        //   normal: require("../static/footer/ioc-04.png"),
        //   active: require("../static/footer/ioc--04.png"),
        //   content: '消息',
        //   href: '/message'
        // },
        {
          normal: require("../static/footer/ioc-05.png"),
          active: require("../static/footer/ioc--05.png"),
          content: "我的",
          href: "/user"
        }
      ]
    };
  },
  mounted() {
    this.fetchData();
    if (this.global.isApp) {
      this.apptabar();
    }
  },
  methods: {
    //默认判断是否存在token
    initDate() {
      // const Mtoken = getStore("token")
      // if ( !Mtoken ) {
      //   this.$router.push({
      //     path: '/login'
      //   })
      // }
    },
    getTitle(title) {
      this.title = title;
    },
    fetchData() {
      let RouterStr = this.$route.path;

      if (
        RouterStr.indexOf("home") !== -1 ||
        RouterStr.indexOf("user") !== -1 ||
        RouterStr.indexOf("issue") !== -1 ||
        RouterStr.indexOf("message") !== -1 ||
        RouterStr.indexOf("login") !== -1
      ) {
        this.tabbar = true;
      } else {
        this.tabbar = false;
      }
    }
  },
  created() {
    this.initDate();
  },
  watch: {
    $route: "fetchData"
  }
};
</script>

<style>
@import "./assets/css/animate.css";
@import "../static/css/common/reset.css";
@import "../static/css/common/border.css";

html,
body {
  height: 100%;
}

#app {
  height: 100%;
  background: #f0f0f0;
  /*padding-top: 50px;*/
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.2s;
}

.fade-enter,
.fade-leave-active {
  opacity: 0;
}

.van-icon-arrow-left:before {
  font-size: 35px;
  color: #000;
}

/* 修改tabbar 图片大小 */
.van-tabbar-item__icon img {
  height: 48px;
}

.van-tabbar-item__text {
  font-weight: 700;
}
</style>
